package goTeam.up.cs301.go;

import goTeam.up.cs301.game.GamePlayer;
import goTeam.up.cs301.game.actionMsg.GameAction;

/**
 * A game-move object that a go player sends to the game to make
 * a move.
 * 
 * @author Steven R. Vegdahl
 * @author Matthew Young
 * @version November 2013
 */
public class GoMoveAction extends GameAction
{
	
	/**
	 * Satisfy serializable interface
	 */
	private static final long serialVersionUID = 1715128677657904097L;
	
	
	// instance variables: the selected row and column
    private int row;
    private int col;

    private boolean isPass;
    
    /**
	 * @return Whether or not this is a passing action
	 */
	public boolean isPass() {
		return isPass;
	}

	/**
     * Constructor for GoMoveAction
     *
     * @param source the player making the move
     * @param row the row of the square selected (0-2)
     * @param col the column of the square selected
     */
    public GoMoveAction(GamePlayer player, int row, int col, boolean playerPasses)
    {
        // invoke superclass constructor to set the player
        super(player);

        // set the row and column as passed to us
        this.row = Math.max(0, Math.min(GoHumanPlayer1.NUM_LINES - 1, row));
        this.col = Math.max(0, Math.min(GoHumanPlayer1.NUM_LINES - 1, col));
        
        isPass = playerPasses;
    }

    /**
     * get the object's row
     *
     * @return the row selected
     */
    public int getRow() { return row; }

    /**
     * get the object's column
     *
     * @return the column selected
     */
    public int getCol() { return col; }

}
